package com.tanhua.api.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.User;
import com.tanhua.mapper.UserMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

@Service  // 导入dubbo注解
public class UserApiImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Long saveUser(User user) {
        userMapper.insert(user);
        return user.getId();  // 支持主键返回
    }

    @Override
    public User findByPhone(String phone) {
        // 创建查询对象
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("phone", phone);
        return userMapper.selectOne(qw);
    }
}
